package com.leetcode.algorithm.y22.m09.w2;

/**
 * 1827. 最少操作使数组递增
 * 
 * https://leetcode.cn/problems/minimum-operations-to-make-the-array-increasing/
 * 
 * @author jie.deng
 *
 */
class Question1827Solution01 {
	
	public int minOperations(int[] nums) {
		int sum = 0;
		int num = nums[0] + 1;
		for (int i = 1; i < nums.length; i++) {
			if (nums[i] < num) {
				sum += (num - nums[i]);
				num++;
			} else {
				num = nums[i] + 1;
			}
		}
		return sum;
	}
    
}